<template>
  <div>
    <div id="top" v-for="(book, id) in books" :key="id">
      <div class="shang">
        <div class="tou">
          <span class="iconfont icon-jingcha"></span>
        </div>
        <div id="youbian">
          <h3>{{ book.wenben1 }}</h3>
          <p>
            <a href="#">{{ book.wenben2 }}</a>
          </p>
        </div>
      </div>

      <ul>
        <li>
          <span>{{ book.shuzi1 }}</span>
          <span>{{ book.wenben3 }}</span>
        </li>
        <li>|</li>
        <li>
          <span>{{ book.shuzi2 }}</span>
          <span>{{ book.wenben4 }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  name: "App",
  components: {},
  data() {
    return {
      books: [],
    };
  },
  created() {
    let xhr = new XMLHttpRequest();
    xhr.open("get", "http://localhost:3000/wode");
    xhr.onreadystatechange = () => {
      if (xhr.readyState == 4 && xhr.status == 200) {
        console.log("xhr.responseText", xhr.responseText);
        this.books = JSON.parse(xhr.responseText);
      }
    };
    xhr.send();
  },
};
</script>

<style scoped>
#top{
  height: 10rem;
  width: 100%;
  background: #4259f4;
  border-end-start-radius: 45%;
  border-end-end-radius: 45%;
}

#top .shang {
  height: 3rem;
  width: 100%;
  
  /* background: brown; */
  margin-top: 0.5rem;
  margin-left: 0.2rem;
  display: flex;
  background: #4259f4;
 justify-content: flex-start;
}

.top .shang .tou span {
  width: 3rem;
  height: 3rem;
 
  /* background: burlywood; */
  border-radius: 50%;
  font-size: 1.5rem;
  color: white;
}
 #youbian {
  margin-left: 0.2rem;
  margin-top: 0.1rem;
  letter-spacing: 0.02rem;
  display: flex;
  align-items: flex-start;
  
  flex-direction: column;
}

#top .shang #youbian h3 {
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
}

#top .shang #youbian a {
  color: #fff;
  font-size: 0.16rem;
  /* margin-top: 3rem; */
  position: relative;
}
#top ul {
  display: flex;
  width: 80%;
  height: 0.5rem;
  justify-content: space-between;
  margin: auto;
  color: #fff;
  margin-top: 0.1rem;
  position: relative;
  margin-top: 3rem;
}

.top ul li {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.top ul li span:first-child {
  margin-bottom: 0.1rem;
}
</style>
